﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {   //判断字符串是否为空
            Console.WriteLine("请输入一个字符串");
            string str = Console.ReadLine();
            StringUtil.Panduan(str);
            //判断数组值是否为null
            string  [] arr = new string[]{ "张三","李四","王五" };
            arr[1] = null;
            ArrayUtil.Shuzhu(arr);
        }
    }
    class ArrayUtil
    {
        public static void Shuzhu(string [] arr) 
        {
            if (arr.Length == 0) { Console.WriteLine("数组长度为0"); }
            for (int i = 0; i <arr.Length; i++)
            {
                if (arr[i] == null) { Console.WriteLine("索引为{0}的值为null",i); }
            }
           

         }
    }
    class StringUtil
    {
        public static void Panduan(string str)
        {

            int num = 0;
            foreach (var item in str)
            {
                if (char.IsWhiteSpace(item)) { num++; }
            }
            if (num == str.Length || num > str.Length) { Console.WriteLine("这是个空的字符串"); }
            else { Console.WriteLine("不为空"); };
        }
    }
}
